<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>年度预算查询及审核</title>
		<meta http-equiv="Pragma" CONTENT="no-cache">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="renderer" content="webkit">
		<link rel="stylesheet" href="${cxt!}/sb/plugins/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
		<%include("/common/include.html"){}%>
	</head>
	
	<body class="easyui-layout">
			<div data-options="region:'north',split: true,title:'快速查询'" style="height:200px;padding:10px;">
				<form id="budgetYearStatisticFrom" >
				   <div style="margin-bottom: 10px;float:left;">
						<label class="label-top" style="width: 100%; display: block;">开始时间</label>
						<input id="budgetYearStatist_startyear" name="startYear" class="easyui-numberspinner theme-textbox-radius" style="width:212px;height: 32px;text-align: center;" value='${date(),dateFormat="yyyy"}' data-options="min:1990,editable:false,label:'年'" labelPosition="after">~ 
					</div>
					<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
						<label class="label-top" style="width: 100%; display: block;">结束时间</label>
						<input id="budgetYearStatist_endyear" name="endYear" class="easyui-numberspinner theme-textbox-radius" style="width:212px;height: 32px;text-align: center;" value='${endYear}' data-options="min:1990,editable:false,label:'年'" labelPosition="after">
					</div>
					<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
						<label class="label-top" style="width: 100%; display: block;">查询门店</label>
						<input id="organ" type="text" readonly style="width: 200px; height: 30px; padding-left: 10px;border-radius:3px" onclick="showMenu(); return false;" class="textbox" value="${organization.name}"/>
						<input name="organIds" id="organIds" type="hidden" value="${organization.ids}">
					</div>
<!-- 					<div style="margin-bottom: 10px;float:left;margin-right: 10px;"> -->
<!-- 						<label class="label-top" style="width: 100%; display: block;">审核状态</label> -->
<!-- 						<select name="checkstate" class=" easyui-combobox theme-textbox-radius" style="width:212px;height:32px;text-align:center" data-options="editable: false"> -->
<!-- 							<option value="-1">请选择</option> -->
<!-- 							<option value="0">未通过</option> -->
<!-- 							<option value="2">正在审核</option> -->
<!-- 							<option value="1">通过</option> -->
<!-- 						</select> -->
<!-- 					</div> -->
					<div style="margin-bottom: 10px;float:left;margin-top: 16px;margin-right: 10px;">
						<a href="#" onclick='searchFrom()' class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="width:212px">搜索</a>
					</div>
				</form>
			</div>
			<div data-options="region:'center'" style="overflow-x:hidden;">
					<div class="easyui-layout">
					<div id="budgetYearStatistic_tabs" class="easyui-tabs" style="width:100%;height:500px;margin-top: 10px;">
						<div title="年度预算审核" style="padding:10px">
							<table id="auditBudgetYear_datagrid"  style="width: 100%; height: 100%;">
								<thead frozen="true">
										<tr>
											<th data-options="field:'ids',hidden:true">预算ids</th>
											<th data-options="field:'organids',hidden:true">门店ids</th>
											<th data-options="field:'organname',width:80,align:'center'">门店</th>
										</tr>
								</thead>
								<thead >
									<tr>
										<th data-options="field:'subyear',width:80,align:'center'">预算年份</th>
										<th data-options="field:'subtime',width:100,align:'center'">提交预算时间</th>
										<th data-options="field:'subuser',width:80,align:'center'">提交预算用户</th>
										<th data-options="field:'subtype',width:80,align:'center'" formatter='ischange'>是否更改</th>
										<th data-options="field:'checkstate',width:80,align:'center'" formatter='checkstate'>审核状态</th>
										<th data-options="field:'gxsj',width:100,align:'center'">更新时间</th>
										<th data-options="field:'budgetinfo',width:80,align:'center'" formatter='budgetinfo'>预算明细</th>
										<th data-options="field:'operate',width:200,align:'center'" formatter='operate'>操作</th>
									</tr>
								</thead>
							</table>
						</div>
						<div title="年度预算查询" style="padding:10px">
							<table id="queryBudgetYear_datagrid"  style="width: 100%; height: 100%;">
								<thead frozen="true">
										<tr>
											<th data-options="field:'ids',hidden:true">预算ids</th>
											<th data-options="field:'organids',hidden:true">门店ids</th>
											<th data-options="field:'organname',width:80,align:'center'">门店</th>
										</tr>
								</thead>
								<thead >
									<tr>
										<th data-options="field:'subyear',width:80,align:'center'">预算年份</th>
										<th data-options="field:'subtime',width:100,align:'center'">提交预算时间</th>
										<th data-options="field:'subuser',width:80,align:'center'">提交预算用户</th>
										<th data-options="field:'subtype',width:80,align:'center'" formatter='ischange'>是否更改</th>
										<th data-options="field:'checkstate',width:80,align:'center'" formatter='checkstate'>审核状态</th>
										<th data-options="field:'checktime',width:100,align:'center'">审核时间</th>
										<th data-options="field:'checkuser',width:80,align:'center'">审核用户</th>
										<th data-options="field:'nocheckreason',width:100,align:'center'">审核未通过原因</th>
										<th data-options="field:'gxsj',width:100,align:'center'">更新时间</th>
										<th data-options="field:'budgetinfo',width:80,align:'center'" formatter='budgetinfo'>预算明细</th>
									</tr>
								</thead> 
							</table>
<!-- 							<div id="querytb" style="height:34px;"> -->
<!-- 								<div style="margin-top: 3px;"> -->
<!-- 									<a href="#" onclick='customerInfo_xlsquery()' class="easyui-linkbutton" data-options="iconCls:'icon-pageexcel'" style="width:67px">导出</a> -->
<!-- 								</div> -->
<!-- 							</div> -->
						</div>
						
					</div>
				</div>
			</div>
			<div id="menuContent" class="menuContent" style="display: none; position: absolute;z-index: 10;">
				<ul id="organSelectTree" class="ztree" style="margin-top:0;width: 200px;"></ul>
			</div>
			<div id="budgetYearStatistic_window" class="easyui-window" title="填写审核不通过原因" style="width:40%;height:47%;"
					data-options="modal:false,closed:true" >
					<label  style="width: 90%; display: block;padding-left: 27px;font-size: 12px;padding-top: 25px;">未通过原因:</label>
					<div style="width:90%;margin-top:25px;margin-left: 27px;" >
						<input class="easyui-textbox theme-textbox-radius" data-options="multiline:true" style="width:100%;height:100px">
					</div>	
					
<!-- 					<input id="checkReason" class="easyui-textbox theme-textbox-radius" data-options="multiline:true" style="width:80%;height:100px;"> -->
					<div style="margin-top:25px;margin-left: 448px;">
						<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'" style="width:80px;"   onclick="ok()">确定</a>
					</div>
			</div>
			
			<script src="sb/js/statistic/budgetYearStatistic/budgetYearStatistic.js" type="text/javascript" charset="utf-8"></script>
			<script type="text/javascript">
				function  ischange(value,row)
				{
					if(value==0)
					{
						return "否";
					}
					if(value==1)
					{
						return "是";
					}
				}
				function  checkstate(value,row)
				{
					if(value==0)
					{
						return "未通过";
					}
					if(value==1)
					{
						return "已通过";
					}
					if(value==2)
					{
						return "审核中";
					}
				}
				function  budgetinfo(value,row)
				{	
					var ids=row.ids;
					return '<button href="#" style="height:25px;width:50px;background:#00A65A;color:white" onclick="lookBudgetYear(\'' + ids + '\')">查看</button>';
				}
				function  operate(value,row)
				{
					var ids=row.ids;
					return '<button href="#" style="height:25px;width:50px;background:#18AEF6;color:white" onclick="passverification(\'' + ids + '\')">通过</button>&nbsp&nbsp'+'<button href="#" style="height:25px;width:50px;background:#E21918;color:white" onclick="votedown(\'' + ids + '\')">否决</button>';
				}
				function  lookBudgetYear(ids)
				{
					loadViewDialog('店面年度预算表', '${cxt !}/budgetYearStatistic/toShowBudgetYear?ids='+ids);
				}
				
// 				function  customerInfo_xlsquery()
// 				{	
// 					var startTime=$('#startTime').val();
// 					var endTime=$('#endTime').val();
// 					var organIds=$('#organIds').val();
// 					var cushybh=$('#cushybh').val();
// 					var cusname=$('#cusname').val();
// 					var cusphone=$('#cusphone').val();
// 					var outorganIds=$('#outorganIds').val();
// 					var zdyy_select=$('#zdyy_select').combobox("getValue");
// 					var url = "${cxt!}/toShopStatistic/intoexcel?startTime=" + startTime + "&endTime=" + endTime+"&organIds="+organIds+
// 							"&outorganIds="+outorganIds+"&cushybh="+cushybh+"&cusname="+cusname+"&cusphone="+cusphone+"&zdyy_select="+zdyy_select;
// 					window.location.href = url;
					
// 				}
// 				function customerInfo_xlsaudit()
// 				{	
// 					var startTime=$('#startTime').val();
// 					var endTime=$('#endTime').val();
// 					var organIds=$('#organIds').val();
// 					var cushybh=$('#cushybh').val();
// 					var cusname=$('#cusname').val();
// 					var cusphone=$('#cusphone').val();
// 					var intoorganIds=$('#intoorganIds').val();
// 					var zdyy_select=$('#zdyy_select').combobox("getValue");
// 					var url = "${cxt!}/toShopStatistic/outexcel?startTime=" + startTime + "&endTime=" + endTime+"&organIds="+organIds+
// 					"&intoorganIds="+intoorganIds+"&cushybh="+cushybh+"&cusname="+cusname+"&cusphone="+cusphone+"&zdyy_select="+zdyy_select;
// 			window.location.href = url;
// 				}
			</script>
<!-- 		查询门店 -->
		<script type="text/javascript">
			var setting = {
				async : {
					enable : true,
					url : '${cxt!}/common/getOrgenTree',
					autoParam : [ "id=ids" ],//, "name=n", "level=lv"
					type : "post"
				},
				view : {
					dblClickExpand : false
				},
				data : {
					simpleData : {
						enable : true
					}
				},
				callback : {
					onClick : onClick,
					onAsyncSuccess : organTreeOnAsyncSuccess
				}
			};
			var flag=0;//只初始化一次标识
			function organTreeOnAsyncSuccess(event, treeId, msg) {
				if(flag == 0){
					flag = 1;
				}
			}
			function onClick(e, treeId, treeNode) {
				var zTree = $.fn.zTree.getZTreeObj("organSelectTree");
				var path = "";
				var sNodes = zTree.getSelectedNodes();
				if (sNodes.length > 0) {
					var node = sNodes[0].getPath();
					for(var i =0;i<node.length;i++){
						if(i == (node.length-1)){
							path += node[i].name;
						}else{
							path += node[i].name + "/";
						}
						
					}
				}
				var cityObj = $("#organ");
				cityObj.attr("value", path);
				$("#organIds").attr("value", treeNode.id);
				hideMenu();
			}
			function showMenu() {
				var cityObj = $("#organ");
				var cityOffset = $("#organ").offset();
				$("#menuContent").css({
					left : cityOffset.left + "px",
					top : cityOffset.top + cityObj.outerHeight() + "px"
				}).slideDown("fast");
		
				$("body").bind("mousedown", onBodyDown);
			}
			function hideMenu() {
				$("#menuContent").fadeOut("fast");
				$("body").unbind("mousedown", onBodyDown);
			}
			function onBodyDown(event) {
				if (!(event.target.id == "menuBtn"
						|| event.target.id == "menuContent" || $(event.target)
						.parents("#menuContent").length > 0)) {
					hideMenu();
				}
			}
			$.fn.zTree.init($("#organSelectTree"), setting);
		</script>
		
		
	</body>
</html>
